package demo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Project implements Serializable {

	private static final long serialVersionUID = 4725151935279590140L;
	private Long id;
	private Long version;

	private String code;
	private String nameShort;
	private String nameLong;
	private List<Milestone> milestones;

	public Project() {
	}

	public Project(Long id, String code) {
		super();
		this.id = id;
		this.code = code;
	}

	public Project(Long id, String code, String nameShort, String nameLong) {
		super();
		this.id = id;
		this.code = code;
		this.nameShort = nameShort;
		this.nameLong = nameLong;
	}

	public Project(Long id, Long version, String code, String nameShort,
			String nameLong, List<Milestone> milestones) {
		super();
		this.id = id;
		this.version = version;
		this.code = code;
		this.nameShort = nameShort;
		this.nameLong = nameLong;
		this.milestones = milestones;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getVersion() {
		return version;
	}

	public void setVersion(Long version) {
		this.version = version;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getNameShort() {
		return nameShort;
	}

	public void setNameShort(String nameShort) {
		this.nameShort = nameShort;
	}

	public String getNameLong() {
		return nameLong;
	}

	public void setNameLong(String nameLong) {
		this.nameLong = nameLong;
	}

	public List<Milestone> getMilestones() {
		return milestones;
	}

	public void setMilestones(List<Milestone> milestones) {
		this.milestones = milestones;
	}

	public void addMilestone(Milestone milestone) {
		if (milestones == null)
			milestones = new ArrayList<Milestone>();
		milestones.add(milestone);
	}

	@Override
	public String toString() {
		String str = id + "." + " (" + code + ") , milestones: "
				+ (milestones != null ? milestones.size() : 0);
		if (milestones != null)
			for (Milestone m : milestones) {
				str += m;
			}
		return str;
	}

	@Override
	public boolean equals(Object obj) {
		Project p = (Project) obj;
		return this.id == p.id;
	}
}
